<%@ page import="pojo.Order_content" %>
<%@ page import="java.util.List" %>
<%@ page import="pojo.Orders" %><%--
  Created by IntelliJ IDEA.
  User: claw
  Date: 2021/11/2
  Time: 12:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--
显示商户收到的订单
--%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css" href="css/dish.css"/>
    <script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>

    <script type="text/javascript">

<%--     如果单项全部打钩，则该单号的checkbox打钩   --%>
        $(document).ready(function(){
            $(".order_content_check").each(function(i,obj){
                $(obj).click(function(){
                    if(check_order_over(obj)){
                        var c=obj.classList[1]
                        $("#"+c)[0].checked=true
                    }
                })
            })
        })


        //如果单号的checkbox打钩，则单项全部打钩
        $(document).ready(function (){
            $(".order_fi").each(function (i,obj){
                $(obj).click(function (){
                    if (obj.checked){
                        var cks=$("."+obj.id)
                        for(var i=0;i<cks.length;i++){
                            cks[i].checked=true
                        }
                    }

                })
            })
        })

        function check_order_over(obj){
            var cls=obj.classList[1]
            var clz=$("."+cls)
            for(var i=0;i<clz.length;i++){
                if (clz[i].checked==false)
                    return false
            }
            return true
        }
    </script>
    <title></title>
</head>

<body>
<form action="bus_finishServlet.do" method="get">
    <% List<Order_content> order_contentList = (List<Order_content>)request.getAttribute("order_contentList");
        List<Orders> ordersList =(List<Orders>) request.getAttribute("ordersList");
//        request.setAttribute("orderList",ordersList);
//        request.setAttribute("orders_length",ordersList.size());
        for (Orders order:ordersList){
    %>


    <div>
        <nav class="navbar navbar-light bg-light">
            <div class="container">
                <!-- <a class="navbar-brand" href="#"> -->
                <h1>订单<%=order.getOrd_no()%></h1>
                <div class="mui-input-row mui-checkbox ">
                    <h5>是否完成</h5>
                    <input id="order<%=order.getOrd_no()%>" class="order_fi" name="order<%=order.getOrd_no()%>" type="checkbox">
                </div>
                <!-- <h2>dingdan</h2> -->
                <!-- </a> -->
            </div>
        </nav>
    </div>

    <table class="table">
        <thead>
        <tr>
            <th scope="col">流水号</th>
            <th scope="col">订单号</th>
            <th scope="col">菜名</th>
            <th scope="col">数量</th>
            <th scope="col">最终价格</th>
            <th scope="col">是否已完成</th>
        </tr>
        </thead>

        <tbody>
    <% for (Order_content order_content:order_contentList){
            if (order_content.getOrd_no()==order.getOrd_no()){
                request.setAttribute("order_num",order);
        %>
    <tr>
        <th scope="row"><%=order_content.getCon_id()%></th>
        <td><%=order_content.getOrd_no()%></td>
        <td><%=order_content.getDi_name()%></td>
        <td><%=order_content.getDi_num()%></td>
        <td><%=order_content.getFi_price()%></td>
        <td>
            <div class="mui-input-row mui-checkbox ">
<%--                id="order<%=order_content.getCon_id()%>"--%>
                <input class="order_content_check order<%=order_content.getOrd_no()%>"  type="checkbox">
            </div>
        </td>
    </tr>
    <%
                }
            }
    %>
    </tbody>
</table>
<%
    }
%>

    <div align="center">
        <button class="btn btn-primary" type="submit" style="margin-top: 20px;" >结束营业</button>
    </div>

</form>
</body>
</html>
